package cn.starlightsoftware.sherly.db.mapper.user;

import cn.starlightsoftware.sherly.controller.admin.user.vo.UserPageReqVO;
import cn.starlightsoftware.sherly.db.model.user.UserDO;
import cn.starlightsoftware.sherly.framework.mybatisplus.mapper.SherlyMapper;
import cn.starlightsoftware.sherly.framework.mybatisplus.wrapper.SherlyLambdaQueryWrapper;
import cn.starlightsoftware.sherly.model.PageResult;

/**
 * @author 谷子毅
 */
public interface UserMapper extends SherlyMapper<UserDO> {

    default PageResult<UserDO> selectPage(UserPageReqVO reqVO) {
        return selectPage(reqVO, UserDO.class, new SherlyLambdaQueryWrapper<UserDO>()
                .eqIfExist(UserDO::getUsername, reqVO.getUsername())
                .eqIfExist(UserDO::getNickname, reqVO.getNickname())
                .eqIfExist(UserDO::getPhone, reqVO.getPhone())
                .eqIfExist(UserDO::getEmail, reqVO.getEmail())
                .eqIfExist(UserDO::getUsable, reqVO.getUsable())
                .betweenIfExist(UserDO::getCreateTime, reqVO.getCreateTime())
        );
    }

}
